package com.hanxin.controller;

import com.hanxin.pojo.Result;
import com.hanxin.pojo.TAudit;
import com.hanxin.pojo.Twoindex;
import com.hanxin.service.AppealAddService;
import com.hanxin.service.AppealService;
import com.hanxin.utils.AppealDto;
import com.hanxin.utils.EditAppeal;
import com.hanxin.utils.EditJkf;
import com.hanxin.utils.InformationDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "成绩申诉信息")
@RequestMapping("/appeal")
public class AppealController {

    @Autowired
    private AppealService appealService;
    @Autowired
    private AppealAddService appealAddService;

    @PostMapping("/appealInformation")
    @ApiOperation(value = "成绩申诉信息查询")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> appealInformation(@RequestBody AppealDto appealDto){
        System.out.println(appealDto);
        return appealService.getAppeal(appealDto);
    }
    @PostMapping("/deleteInformation")
    @ApiOperation(value = "成绩申诉删除")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> deleteInformation(@RequestBody  List<Integer> ids){
        System.out.println("ids:--------------------"+ids);
        return appealService.deleteByIds(ids);
    }

    @PostMapping("/subInformation")
    @ApiOperation(value = "成绩申诉提交")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> subInformation(@RequestBody  List<Integer> ids){
        System.out.println("ids:--------------------"+ids);
        return appealService.subByids(ids);
    }

    @PostMapping("/subzInformation")
    @ApiOperation(value = "成绩申诉撤回提交")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> subzInformation(@RequestBody  List<Integer> ids){
        System.out.println("ids:--------------------"+ids);
        return appealService.subzByids(ids);
    }

    @PostMapping("/editGetInformation")
    @ApiOperation(value = "成绩申诉编辑查询缓存数据显示在页面上")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> editGetInformation(@RequestBody EditAppeal editAppeal){
        return appealService.editCacheCheck(editAppeal);
    }

    @PostMapping("/editCheckInformation")
    @ApiOperation(value = "成绩申诉编辑没有缓存查看")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> editCheckInformation(@RequestBody EditAppeal editAppeal){
        return appealService.editNoCacheCheck(editAppeal);
    }

    @PostMapping("/editInformation")
    @ApiOperation(value = "成绩申诉编辑")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> editInformation(@RequestBody EditAppeal editAppeal){
        return appealService.editCheck(editAppeal);
    }

    @PostMapping("/cancelInformation")
    @ApiOperation(value = "成绩申诉编辑缓存")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> cancelInformation(@RequestBody EditAppeal editAppeal){
        return appealService.cancelAppeal(editAppeal);
    }

    @PostMapping("/appealAddGetInformation")
    @ApiOperation(value = "成绩申诉新增默认查询")
    @ApiResponses({ @ApiResponse(code = 200, message = "请求成功", response = TAudit.class),
            @ApiResponse(code = 404, message = "信息不存在") })
    @ResponseBody
    @CrossOrigin
    public Result<Object> appealAddGetInformation(){
        return appealAddService.addGetAppeal();
    }
}
